package com.sikaryofficial.backend.service.points;

import com.sikaryofficial.backend.constant.ActivityConstant;
import com.sikaryofficial.backend.service.IPointsDetailStrategy;
import com.sikaryofficial.common.core.constant.PointRuleConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author : qinjinyuan
 * @desc : 刮刮乐 虚拟积分处理服务
 * @date : 2023/10/31 18:58
 */
@Service(value = PointRuleConstant.LOTTERY_SCRATCH + IPointsDetailStrategy.SUFFIX)
@Slf4j
public class LotteryScratchPointsService extends AbstractPointService {
    /**
     * 更新积分明细数据
     *
     * @param sourceId          积分来源ID
     * @param userId            用户ID
     * @param pointsDetailValue 积分
     * @return true / false
     */
    @Override
    public boolean updatePointsByInputValue(Long sourceId, Long userId, Integer pointsDetailValue, String param, String sourceName) {
        if (ActivityConstant.REDUCE.equals(param)) {
            return this.reducePoints(sourceId, userId, pointsDetailValue, PointRuleConstant.LOTTERY_SCRATCH, sourceName);
        } else {
            return this.increasePoints(sourceId, userId, PointRuleConstant.LOTTERY_SCRATCH, pointsDetailValue, sourceName);
        }
    }
}
